<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>融易拍-注册</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="/static/wx/lib/sui/sm.min.css">
    <link rel="stylesheet" href="/static/wx/lib/sui/sm-extend.min.css">
    <link rel="stylesheet" href="/static/wx/css/reset.css">
    <link rel="stylesheet" href="/static/wx/css/main.css">
    <link rel="stylesheet" href="/static/wx/css/public_main.css">
</head>

<body>
    <div class="page-group">
        <div class="page page-current" id="regist">
            <div class="bar bar-standard bar-footer text-c size-m" style="line-height:2.2rem;">
               <span>
                    已经有账号了？<a class="red external" href="/wx/login/login">登录</a>
               </span> 
            </div>
            <!-- 主内容 -->
            <div class="content">
                <div class="logo-box">
                    <div class="logo-inner">
                        <div class="logo">
                            <img src="/static/wx/imgs/img/reg.png">
                        </div>
                    </div>
                </div>
                <div class="regist-form">
                    <div class="input-wrapper">
                        <img src="/static/wx/imgs/icon/mobile.png">
                        <div class="after-other"></div>
                        <input class="icon-lable" type="text"  placeholder="手机号码" name="phone" value="{$Think.get.phone}">
                        <div class="clean-input size-m coffe">
                            <img src="/static/wx/imgs/icon/close.png">
                        </div>
                    </div>
                    <div class="get-code-box">
                        <div class="input-wrapper" style="width:55%">
                            <img src="/static/wx/imgs/icon/mail.png">
                            <div class="after-other"></div>
                            <input class="icon-lable size-65" type="text" placeholder="请输入验证码" name="code" value="{$Think.get.code}">
                        </div>
                        <div class="get-code size-m" style="width:40%" >
                            获取验证码
                        </div>
                    </div>
                    <div class="my-btn"  style="margin-top: 30px;" id ='registsubmit'>
                        <span class="active">下一步</span>
                    </div>
                    <div class="service-paper size-m">
                        <label>
                            <input type="checkbox" disabled='true'/>
                            <i class="tan"></i>
                            <span>注册代表您同意我们的<a class="red external" href="/wx/login/serveItemsa">《服务条款》</a></span>
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type='text/javascript' src='/static/wx/lib/sui/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/lib/sui/sm.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='/static/wx/lib/sui/sm-extend.min.js' charset='utf-8'></script>
    <!--<script type='text/javascript' src="/static/wx/lib/vue/vue.min.js"></script>-->
    <!--<script type='text/javascript' src="/static/wx/lib/sui/jquery.js"></script>-->
    <script type="text/javascript">
        $(function () {
            var  a =  localStorage.getItem('is_true');
            console.log(a);
           // if(a){$('.service-paper label i').css({'display':'inline-block'})}else{$('.service-paper label i').hide()}
            if(a === '1'){
                $('.service-paper label input').attr('checked',true)
            }else if(a == 2) {
                $(".service-paper label input").removeAttr('checked');
            }

            var countdown = 60;
            $('.coffe').on('touchend',function(){
              $("input[ name='phone']").val('');
            });

            $('.tan').on('click',function(){
                var phone = $("input[ name='phone']").val();
                var code = $("input[ name='code']").val();
              location.href = "{:url('login/serveItemsa')}?phone="+phone+'&code='+code;
            });
            //短信验证码改变颜色
            function sendmsg() {
                if (countdown == 0) {
                    $(".get-code").css({"background-color": "red"});
                    $(".get-code").html("获取验证码");
                    countdown = 60;
                    return false;
                }
                else {
                    $(".get-code").css({"background-color": "#C0C0C0", "pointer-events": "none"});
                    $(".get-code").html(countdown + "s");
                    countdown--;
                }
                setTimeout(function () {
                    sendmsg();
                }, 1000);
            }
            //获取验证码
            $(document).on('click','.get-code',function () {
                var pattern = /^1[1345678]\d{9}$/;
                var phone = $("input[ name='phone']").val();
                if (pattern.test(phone) === false) {
                    $.alert('请输入正确的手机号');
                    return;
                }
                $.ajax({
                    type: 'POST',
                    url: '/wx/Login/sendSms',
                    data: {
                        'phone': phone,
                        'type': 2
                    },
                    dataType: 'json',
                    success: function (Json) {
                        if (Json.code == 200) {
                           var  takse = Json.data.code_id;
                            localStorage.setItem('takse',takse);
                         //   console.log(takse);
                            $.alert('发送成功');
                            sendmsg();
                        } else {
                            $.alert('发送失败');
                        }
                    }
                });
            });
            //注册
            $(document).on('click','#registsubmit',function () {
                var pattern = /^1[1345678]\d{9}$/;
                var phone = $("input[ name='phone']").val();
                var code = $("input[ name='code']").val();
                if(a !== '1'){
                    $.alert('请先同意服务条款');
                    return;
                }
                // pattern.test(phone);
                if (pattern.test(phone) === false) {
                    $.alert('请输入正确的手机号');
                    return;
                }
                if(code.length==0){
                    $.alert('请输入验证码');
                    return;
                }
                if(localStorage.getItem('takse') ==''){
                    $.alert('您的验证码已失效,请重新获取验证码');
                    return;
                }
                $.ajax({
                    type: 'POST',
                    url: '/wx/Login/register',
                    data: {
                        'phone': phone,
                        'code': code,
                        'tickets': localStorage.getItem('takse')
                    },
                    dataType: 'json',
                    success: function (Json) {
                        console.log(Json);
                        if (Json.code == 200) {
                            info=Json.data;
location.href="{:url('login/checkInfo')}?uid="+info.uid+"&username="+info.username+"&mobile="+info.mobile+"&company_name="+info.company_name+"&role_id="+info.role_id+"&card_num="+info.card_num+"&role_id="+info.role_id+"&c_company_name="+info.c_company_name+"&c_name="+info.c_name+"&c_mobile="+info.c_mobile;
                        } else {
                            $.alert(Json.msg);
                        }
                    }
                });
            });


        });


    </script>
</body>

</html>